<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="UTF-8" />
    <title>Item - Counter</title>
    <meta
      name="viewport"
      content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
    />
    <link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
    <link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
    <script src="../../../../../scripts/testing/scripts.js"></script>
    <script nomodule src="../../../../../dist/ionic/ionic.js"></script>
    <script type="module" src="../../../../../dist/ionic/ionic.esm.js"></script>
  </head>

  <body>
    <ion-app>
      <ion-header>
        <ion-toolbar>
          <ion-title>Item counter</ion-title>
        </ion-toolbar>
      </ion-header>

      <ion-content class="ion-padding-vertical">
        <ion-list>
          <ion-item counter="true">
            <ion-label position="stacked">Counter</ion-label>
            <ion-input maxlength="20"></ion-input>
          </ion-item>

          <ion-item counter="true">
            <ion-label position="stacked">Counter with value</ion-label>
            <ion-input maxlength="20" value="some value"></ion-input>
          </ion-item>

          <ion-item counter="true" id="customFormatter">
            <ion-label position="stacked">Counter with custom formatter</ion-label>
            <ion-input maxlength="20" value=""></ion-input>
          </ion-item>
        </ion-list>
      </ion-content>
    </ion-app>

    <script>
      const customFormatter = document.getElementById('customFormatter');
      customFormatter.counterFormatter = (inputLength, maxLength) => {
        return `${maxLength - inputLength} characters left`;
      };
    </script>
  </body>
</html>
